home *** CD-ROM | disk | FTP | other *** search
/ Pascal Super Library / Pascal Super Library (CW International)(1997).bin / BORL_TIP / TI1000 / TI1759.ASC < prev    next >
Text File  |  1994-01-10  |  4KB  |  199 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.   PRODUCT  :  Pascal                                NUMBER  :  1759
  9.   VERSION  :  6.0 & up
  10.        OS  :  DOS
  11.      DATE  :  January 10, 1994                         PAGE  :  1/3
  12.  
  13.     TITLE  :  Getting and setting a disks serial number
  14.  
  15.  
  16.  
  17.  
  18.   The following program shows how to read and write the serial
  19.   number on a disk drive. It uses interrupt $21 function $69
  20.   and reads the information back and forth into a record with
  21.   the following declaration:
  22.  
  23.     TSerPacket = record
  24.       Info:Word;
  25.       SerNo: Longint;
  26.       Vol: Array[1..11] of char;
  27.       FileType: Array[1..8] of char;
  28.     end;
  29.  
  30.   The first word of the above record should always contain
  31.   zero, the second contains the serial number, the third
  32.   the volume label and the fourth the FileType, which is usually
  33.   either FAT 16 or FAT 12.
  34.  
  35.   When setting a new serial number, the programs first reads the
  36.   current information, and then sets the new serial number
  37.   and writes it to disk.
  38.  
  39.   The code shown below provides the user with three functions:
  40.  
  41.     GetSerialInfo: Get the current serial number
  42.     SetSerialInfo: Set a new serial number
  43.     DisplaySerialInfo: Display the information in the current
  44.                        variable of type TPacket.
  45.  
  46.   Notice that DisplaySerialInfo does not write information
  47.   to a disk drive, but only displays that information to
  48.   the user via the screen. All of these routines depend
  49.   on a global variable of type TSerPacket, which is called
  50.   SPacket. It makes no sense to call DisplaySerialInfo
  51.   before calling GetSerialInfo.
  52.  
  53.   The drive specification is passed as a number, where
  54.   the default drive is zero, drive A is one, drive
  55.   B is two, etc.
  56.  
  57.  
  58.   program SetDiskSer;
  59.  
  60.   {$A+,B-,D+,E+,F-,G+,I+,L+,N-,O-,P-,Q-,R-,S-,T-,V+,X+,Y+}
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73.  
  74.   PRODUCT  :  Pascal                                NUMBER  :  1759
  75.   VERSION  :  6.0 & up
  76.        OS  :  DOS
  77.      DATE  :  January 10, 1994                         PAGE  :  2/3
  78.  
  79.     TITLE  :  Getting and setting a disks serial number
  80.  
  81.  
  82.  
  83.  
  84.   {$M 16384,0,655360}
  85.  
  86.   type
  87.     TSerPacket = record
  88.       Info:Word;        { Info level always zero }
  89.       SerNo: Longint;   { Disk }
  90.       Vol: Array[1..11] of char;
  91.       FileType: Array[1..8] of char;
  92.     end;
  93.  
  94.   var
  95.     SPacket: TSerPacket;
  96.  
  97.   function GetSerialInfo(Drive: Byte): Byte; assembler;
  98.   asm
  99.     mov ah, 69h
  100.     mov al, 0  { This is where you 1 set serial, 0 to get serial
  101.                  number }
  102.     mov bl, 1  { drive number 0 = default, 1 = A, 2 = B , 3 = C }
  103.     mov dx, offset [SPacket]
  104.     int 21h
  105.   end;
  106.  
  107.  
  108.   function SetSerialInfo(Drive: Byte; SerNo: LongInt): Boolean;
  109.   var
  110.     S: String;
  111.   begin
  112.     GetSerialInfo(Drive);
  113.     SPacket.SerNo := SerNo;
  114.     asm
  115.       mov ah, 69h
  116.       mov al, 1  { This is where you 1 set serial, 0 to get serial
  117.                    number }
  118.       mov bl, Drive  { drive number 0 = default, 1 = A, 2 = B ,
  119.                        3 = C }
  120.       mov dx, offset [SPacket]
  121.       int 21h
  122.     end;
  123.   end;
  124.  
  125.   procedure DisplaySerialInfo;
  126.   var
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.  
  137.  
  138.  
  139.  
  140.   PRODUCT  :  Pascal                                NUMBER  :  1759
  141.   VERSION  :  6.0 & up
  142.        OS  :  DOS
  143.      DATE  :  January 10, 1994                         PAGE  :  3/3
  144.  
  145.     TITLE  :  Getting and setting a disks serial number
  146.  
  147.  
  148.  
  149.  
  150.     S: String;
  151.   begin
  152.     WriteLn('Info level: ', SPacket.Info);
  153.     WriteLn('Serial Num: ', SPacket.SerNo);
  154.     FillChar(S, SizeOf(S), #0);
  155.     Move(SPacket.Vol[1], S[1], 11);
  156.     S[0] := #11;
  157.     WriteLn('Vol: ', S);
  158.     FillChar(S, SizeOf(S), #0);
  159.     Move(Spacket.FileType,S[1], 8);
  160.     S[0] := #8;
  161.     WriteLn('Type: ', S);
  162.   end;
  163.  
  164.   begin
  165.     SetSerialInfo(1, 12);  { One means Drive A, 16 is the serial
  166.                              number }
  167.     GetSerialInfo(1);
  168.     DisplaySerialInfo;
  169.     ReadLn;
  170.   end.
  171.  
  172.   DISCLAIMER: You have the right to use this technical information
  173.   subject to the terms of the No-Nonsense License Statement that
  174.   you received with the Borland product to which this information
  175.   pertains.
  176.  
  177.  
  178.  
  179.  
  180.  
  181.  
  182.  
  183.  
  184.  
  185.  
  186.  
  187.  
  188.  
  189.  
  190.  
  191.  
  192.  
  193.  
  194.  
  195.  
  196.  
  197.  
  198.  
  199.